package com.zego.wawaji.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.zego.wawaji.base.module.ModuleMgr;
import com.zego.wawaji.ui.activity.MainActivity;
import com.zego.wawaji.ui.activity.web.WebActivity;
import com.zego.wawaji.ui.bean.wawa.WawaJi;
import com.zego.wawaji.ui.center.about.AboutAct;
import com.zego.wawaji.ui.center.address.MyAddressAct;
import com.zego.wawaji.ui.center.address.MyEditAddressAct;
import com.zego.wawaji.ui.center.address.bean.Address;
import com.zego.wawaji.ui.center.credit.MyCreditAct;
import com.zego.wawaji.ui.center.invite.InviteAct;
import com.zego.wawaji.ui.center.pay.award.PayAwardActivity;
import com.zego.wawaji.ui.center.pay.bill.MyBillAct;
import com.zego.wawaji.ui.center.question.QuestionActivity;
import com.zego.wawaji.ui.center.question.QuestionAddAct;
import com.zego.wawaji.ui.center.question.QuestionMyAct;
import com.zego.wawaji.ui.center.set.SettingAct;
import com.zego.wawaji.ui.center.transport.WawaLogisticsAct;
import com.zego.wawaji.ui.center.transport.bean.StepList;
import com.zego.wawaji.ui.coupon.activity.CouponActivity;
import com.zego.wawaji.ui.play.PlayActivity;
import com.zego.wawaji.ui.rank.bean.Award;
import com.zego.wawaji.ui.rank.order.PrizeOrderActivity;
import com.zego.wawaji.ui.rank.prize.MyPrizeActivity;
import com.zego.wawaji.ui.rank.virtual.VirtualPrizeActivity;
import com.zego.wawaji.ui.start.NavUserAct;
import com.zego.wawaji.ui.store.bean.Store;
import com.zego.wawaji.ui.store.convert.StoreConvertActivity;
import com.zego.wawaji.ui.store.declare.StoreDeclareActivity;
import com.zego.wawaji.ui.store.order.StoreOrderActivity;
import com.zego.wawaji.ui.wawa.synth.SynthWawaActivity;
import com.zego.wawaji.ui.wawa.synth.gallery.SynthGalleryActivity;
import com.zego.wawaji.ui.wawa.synth.material.SynthMaterialActivity;

/**
 * Created by Su on 2017/11/24.
 */
public class UIShow {

    public static void show(Context context, Intent intent) {
        context.startActivity(intent);
    }

    public static void show(Context context, Class clz, int flag) {
        Intent intent = new Intent(context, clz);
        if (flag != -1) intent.addFlags(flag);
        show(context, intent);
    }

    public static void show(Context context, Class clz) {
        show(context, clz, -1);
    }

    /**
     * 显示activity并清空栈里其他activity
     *
     * @param activity 要启动的activity
     */
    public static void showActivityClearTask(Context context, Class activity) {
        show(context, activity, Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    }

    /**
     * 跳转到主页并清除栈里的其他页面
     */
    public static void showMainClearTask(Context context) {
        showActivityClearTask(context, MainActivity.class);
    }

    /**
     * 跳转到网页
     *
     * @param type 1-侧滑页面，2-全屏页面，全屏时显示loading条  3-京东商品详情页  4-充值排行榜
     * @param url  网页地址
     */
    public static void showWebActivity(Context context, int type, String url) {
        Intent intent = new Intent(context, WebActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("url", url);
        intent.putExtra("type", type);
        show(context, intent);
    }

    /**
     * 打开导航页
     */
    public static void showNavUserAct(Context context) {
//        Intent intent = new Intent(context, NavUserAct.class);
//        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//        context.startActivity(intent);
        showActivityClearTask(context, NavUserAct.class);
    }

    /**
     * 打开设置页
     */
    public static void showSettingAct(Activity activity) {
        activity.startActivity(new Intent(activity, SettingAct.class));
    }

    /**
     * 问题反馈
     */
    public static void showQuestionAct(Activity activity) {
        activity.startActivity(new Intent(activity, QuestionActivity.class));
    }

    /**
     * 提交问题
     */
    public static void showQuestionAddAct(Activity activity) {
        activity.startActivity(new Intent(activity, QuestionAddAct.class));
    }

    /**
     * 我的反馈
     */
    public static void showQuestionMyAct(Activity activity) {
        activity.startActivity(new Intent(activity, QuestionMyAct.class));
    }

    /**
     * 打开游戏页
     *
     * @param room 房间信息
     */
    public static void showPlayActivity(Activity activity, WawaJi room) {
        Intent intent = new Intent(activity, PlayActivity.class);
        intent.putExtra("room", room);
        ModuleMgr.getWawaMgr().setLastWawaJi(room);
        activity.startActivity(intent);
    }

    /**
     * 打开我的娃娃: 物流信息
     */
    public static void showWaWaLogisticsAct(Activity activity, StepList stepList) {
        Intent intent = new Intent(activity, WawaLogisticsAct.class);
        intent.putExtra("stepList", stepList);
        activity.startActivity(intent);
    }

    /**
     * 首充开宝箱
     */
    public static void showPayAwardAct(Activity activity) {
        activity.startActivity(new Intent(activity, PayAwardActivity.class));
    }

    /**
     * 我的娃娃币账单
     */
    public static void showMyBillAct(Activity activity) {
        activity.startActivity(new Intent(activity, MyBillAct.class));
    }

    /**
     * 我的积分
     */
    public static void showMyCreditAct(Activity activity) {
        activity.startActivity(new Intent(activity, MyCreditAct.class));
    }

    /**
     * 邀请他人
     */
    public static void showInviteAct(Activity activity) {
        activity.startActivity(new Intent(activity, InviteAct.class));
    }

    /**
     * 关于我们
     */
    public static void showAboutAct(Activity activity) {
        activity.startActivity(new Intent(activity, AboutAct.class));
    }

    /**
     * 收获地址
     *
     * @param channel 来源： 0： 添加收获地址  1： 确认发货  2: 充值排行榜发货
     * @param ids     需发货的娃娃
     */
    public static void showMyAddressAct(Activity activity, int channel, String ids) {
        Intent intent = new Intent(activity, MyAddressAct.class);
        intent.putExtra("channel", channel);
        intent.putExtra("strIds", ids);
        activity.startActivity(intent);
    }

    public static void showMyAddressAct(Activity activity) {
        showMyAddressAct(activity, 0, "");
    }

    public static void showMyAddressPrizeAct(Activity activity, String ids) {
        Intent intent = new Intent(activity, MyAddressAct.class);
        intent.putExtra("channel", 2);
        intent.putExtra("ids", ids);
        activity.startActivity(intent);
    }


    /**
     * 收获地址: 编辑
     */
    public static void showMyEditAddressAct(Activity activity, Address address) {
        Intent intent = new Intent(activity, MyEditAddressAct.class);
        intent.putExtra("Address", address);
        activity.startActivity(intent);
    }

    /**
     * 我的订单
     */
    public static void showStoreOrderActivity(Activity activity) {
        Intent intent = new Intent(activity, StoreOrderActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 商品：立即兑换
     */
    public static void showStoreConvertActivity(Activity activity, Store store) {
        Intent intent = new Intent(activity, StoreConvertActivity.class);
        intent.putExtra("store", store);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：虚拟奖品
     */
    public static void showStoreDeclareActivity(Activity activity) {
        Intent intent = new Intent(activity, StoreDeclareActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：我的奖品
     */
    public static void showMyPrizeActivity(Activity activity) {
        Intent intent = new Intent(activity, MyPrizeActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：虚拟奖品
     */
    public static void showVirtualPrizeActivity(Activity activity, Award award) {
        Intent intent = new Intent(activity, VirtualPrizeActivity.class);
        intent.putExtra("award", award);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：发货订单
     */
    public static void showPrizeOrderActivity(Activity activity) {
        Intent intent = new Intent(activity, PrizeOrderActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 我的优惠券
     */
    public static void showCouponActivity(Activity activity) {
        Intent intent = new Intent(activity, CouponActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 合成娃娃
     */
    public static void showSynthWawaActivity(Activity activity) {
        activity.startActivity(new Intent(activity, SynthWawaActivity.class));
    }

    /**
     * 合成娃娃图鉴
     */
    public static void showSynthGalleryActivity(Activity activity) {
        activity.startActivity(new Intent(activity, SynthGalleryActivity.class));
    }

    /**
     * 合成娃娃材料
     */
    public static void showSynthMaterialActivity(Activity activity) {
        activity.startActivity(new Intent(activity, SynthMaterialActivity.class));
    }
}
